package com.zhihaoliang.coroutine.buss.net.util.http

import android.widget.Toast
import com.zhihaoliang.coroutine.CoroutineApp
import com.zhihaoliang.coroutine.util.log
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

/**
 * @author 支豪亮
 * @date 2022/10/14 17:17
 * @des
 */
class NetCallback<T>(private val dataLoad:IDataLoad<T?>):Callback<T> {
    override fun onResponse(call: Call<T>, response: Response<T>) {
        dataLoad.onDataLoad(response.body())
    }

    override fun onFailure(call: Call<T>, t: Throwable) {
        log(t.toString())
        Toast.makeText(CoroutineApp.instance, "数据加载失败", Toast.LENGTH_LONG).show()
    }

}